﻿/*************************************************
作者: Plane
邮箱: 1785275942@qq.com
功能: 消息事件通知服务

           ~~获取更多教学资讯~~
//----------------*----------------\\
        教学官网：www.qiqiker.com
        官方微信服务号: qiqikertuts
        Plane老师微信: PlaneZhong
\\----------------*----------------//
*************************************************/

using System;

public enum EvtID {
    None,
    OnRoleDataUpdated,

    OnTaskInfoUpdated,

    OnSelfPlayerCreated,

    //...
}

public class EvtSvc : ILogic {
    //-------------Declaration----------------//
    readonly PEMsger<EvtID> msger = new();

    //-------------Flow Functions-------------//
    public void Init() {
        msger.MsgerInit();
        this.Log("Init EvtSvc Done.");
    }
    public void Tick() {
        msger.MsgerTick();
    }
    public void UnInit() {
        msger.MsgerUnInit();
        this.Log("UnInit EvtSvc.");
    }

    //-------------Tool Functions-------------//
    public void AddListener(EvtID evt, Action<object, object> cb) {
        msger.AddMsgHandler(evt, cb);
    }
    public void RmvListener(EvtID evt) {
        msger.RmvHandlerByMsgID(evt);
    }
    public void RmvTargetListener(object target) {
        msger.RmvHandlerByTarget(target);
    }
    public void SendEvt(EvtID evt, object param1 = null, object param2 = null) {
        msger.InvokeMsgHandler(evt, param1, param2);
    }
    public void SendEvtImmediately(EvtID evt, object param1 = null, object param2 = null) {
        msger.InvokeMsgHandlerImmediately(evt, param1, param2);
    }
}